Free handles when done.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 17 Apr 2003 03:53:21 +0000 (03:53 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 17 Apr 2003 03:53:21 +0000 (03:53 +0000)
Copy from and free jeeps structures when reading from Garmin.

gpsbabel/garmin.c

index 1478d3ef5e999f4d6a145ba89aad2ddbc70b8742..ce5c824b1b111ebdb5fe9578a5c6b593cb9bfa47 100644 (file)
@@ -53,6 +53,10 @@ rw_init(const char *fname, const char *opts)
 static void
 rw_deinit(void)
 {
+       if (mkshort_handle) {
+               mkshort_del_handle(mkshort_handle);
+               mkshort_handle = NULL;
+       }
 }
 
 static void
@@ -68,8 +72,8 @@ waypt_read(void)
        for (i = 0; i < n; i++) {
                waypoint *wpt_tmp = xcalloc(sizeof(*wpt_tmp),1);
 
-               wpt_tmp->shortname = way[i]->ident;
-               wpt_tmp->description = way[i]->cmnt;
+               wpt_tmp->shortname = xstrdup(way[i]->ident);
+               wpt_tmp->description = xstrdup(way[i]->cmnt);
                wpt_tmp->position.longitude.degrees = way[i]->lon;
                wpt_tmp->position.latitude.degrees = way[i]->lat;
                /*
@@ -91,6 +95,7 @@ waypt_read(void)
                }
                
                waypt_add(wpt_tmp);
+               GPS_Way_Del(&way[i]);
        }
 }
 
@@ -245,6 +250,9 @@ data_write(void)
                                mkshort(mkshort_handle, src) : 
                                wpt->shortname;
                strncpy(way[i]->ident,  ident, sizeof(way[i]->ident));
+               if (global_opts.synthesize_shortnames) { 
+                       xfree(ident);
+               }
                way[i]->ident[sizeof(way[i]->ident)-1] = 0;
                if (src && strlen(src)) {
                        strncpy(way[i]->cmnt, src, sizeof(way[i]->cmnt));